<template>
  <div>
    <!--头部区域-->

    <div style="height: 60px; line-height: 60px;background-color: white;margin-bottom: 2px;display: flex">
      <div style="width: 300px">
        <img src="@/assets/logo.png" alt="" style="width: 40px ;position: relative;top: 10px; left: 10px">
        <span style="margin-left: 25px;font-size: 24px">后台管理</span>
      </div>
      <div style="flex: 1;text-align: right ;padding-right: 20px">

        <el-dropdown size="medium">
            <span class="el-dropdown-link" style="cursor: pointer">
              <el-avatar :src="admin.head"></el-avatar>
              <i class="el-icon-arrow-down el-icon--right"></i>

            </span>
          <el-dropdown-menu slot="dropdown" style="margin-top: -5px">
            <el-dropdown-item>
              <div style="width: 50px; text-align: center" @click="logout">退出</div>
            </el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </div>
    <!--侧边栏和主体-->
    <div style="display: flex">
      <!--侧边栏导航-->
      <div
          style="width: 200px; min-height:calc(100vh - 62px);overflow: hidden;margin-right: 2px;background-color: white">
        <el-menu :default-active="$route.path" router class="el-menu-demo">
          <el-menu-item index="/">
            <i class="el-icon-eleme"></i>
            <span>前台首页</span>
          </el-menu-item>
          <!--会员-->
          <!--                    <el-submenu index="user">-->
          <!--                        <template slot="title">-->
          <!--                            <i class="el-icon-info"></i>-->
          <!--                            <span>会员管理</span>-->
          <!--                        </template>-->
          <!--                        <el-menu-item index="/userList">会员列表</el-menu-item>-->
          <!--                        <el-menu-item index="/addUser">会员添加</el-menu-item>-->
          <!--                    </el-submenu>-->
          <!--管理员-->
          <el-submenu index="admin">
            <template slot="title">
              <i class="el-icon-user"></i>
              <span>人员管理</span>
            </template>
            <el-menu-item index="/adminList">人员列表</el-menu-item>
            <el-menu-item index="/addAdmin">人员添加</el-menu-item>

          </el-submenu>
          <!--图书分类-->
          <!--                    <el-submenu index="category">-->
          <!--                        <template slot="title">-->
          <!--                            <i class="el-icon-s-management"></i>-->
          <!--                            <span>图书分类管理</span>-->
          <!--                        </template>-->
          <!--                        <el-menu-item index="/CategoryList">图书分类列表</el-menu-item>-->
          <!--                        <el-menu-item index="/AddCategory">图书分类添加</el-menu-item>-->

          <!--                    </el-submenu>-->
          <!--图书-->
          <!--                    <el-submenu index="book">-->
          <!--                        <template slot="title">-->
          <!--                            <i class="el-icon-s-management"></i>-->
          <!--                            <span>图书管理</span>-->
          <!--                        </template>-->
          <!--                        <el-menu-item index="/BookList">图书列表</el-menu-item>-->
          <!--                        <el-menu-item index="/AddBook">图书添加</el-menu-item>-->
          <!--                    </el-submenu>-->

          <el-submenu index="fuzhou">
            <template slot="title">
              <i class="el-icon-house"></i>
              <span>走进福州管理</span>
            </template>
            <el-menu-item index="/background">列表</el-menu-item>
          </el-submenu>

          <el-submenu index="travel">
            <template slot="title">
              <i class="el-icon-office-building"></i>
              <span>旅游景点管理</span>
            </template>
            <el-menu-item index="/TravelBackground">旅游景点列表</el-menu-item>
            <el-menu-item index="/AddTravel">添加旅游景点</el-menu-item>
          </el-submenu>

          <el-submenu index="history">
            <template slot="title">
              <i class="el-icon-collection"></i>
              <span>发展历史管理</span>
            </template>
            <el-menu-item index="/HistoryBackground">历史列表</el-menu-item>
          </el-submenu>

          <el-submenu index="message">
            <template slot="title">
              <i class="el-icon-chat-dot-round"></i>
              <span>景点消息留言管理</span>
            </template>
            <el-menu-item index="/MsgBackground">留言列表</el-menu-item>
          </el-submenu>

          <el-submenu index="newFuzhouBackground">
            <template slot="title">
              <i class="el-icon-notebook-2"></i>
              <span>新闻管理</span>
            </template>
            <el-menu-item index="/newFuzhouBackground">新闻列表</el-menu-item>
            <el-menu-item index="/AddnewFuzhou">添加新闻</el-menu-item>
          </el-submenu>

          <el-submenu index="teseBackground">
            <template slot="title">
              <i class="el-icon-notebook-2"></i>
              <span>特色文化</span>
            </template>
            <el-menu-item index="/teseBackground">文化列表</el-menu-item>
          </el-submenu>
          <!--前台页面跳转-->
        </el-menu>
      </div>
      <!--主体数据-->
      <div style="flex: 1 ;background-color: white ;padding: 10px">
        <router-view/>
      </div>

    </div>

  </div>
</template>

<script>
import Cookies from 'js-cookie';

export default {
  name: "Layout.vue",
  data() {
    return {
      //从cookie当中取出当前登录用户数据
      admin: Cookies.get('admin') ? JSON.parse(Cookies.get('admin')) : {}
    }

  },
  methods: {
    logout() {
      //退出时清空cookie
      Cookies.remove('admin')
      this.$router.push("/login")

    }
  }
}
</script>
<style scoped>

</style>
